/*
 * Powered By zhangyunhua
 * Web Site: http://www.hhk.com 
 * Since 2008 - 2012
 */


package com.khh.garment.basedata.crcy.dao.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.khh.garment.basedata.crcy.dao.CrcyDao;
import com.khh.garment.basedata.crcy.entity.Crcy;


public class CrcyDaoHibernateImpl extends HibernateDaoSupport implements CrcyDao {
	
	
	/**
	 * �������޸�
	 * @param crcy
	 */
	public void saveCrcy(Crcy crcy){
		this.getHibernateTemplate().saveOrUpdate(crcy);
	}
	
	/**
	 * ɾ��
	 * @param crcy
	 */
	public void deleteCrcy(Crcy crcy){
		this.getHibernateTemplate().delete(crcy);
	}
	
	/**
	 * ����
	 * @param 
	 * @return
	 */
	public Crcy findBySN(String crcySN){
		Criteria criteria = this.getSession().createCriteria(Crcy.class);
		criteria.add(Restrictions.eq("crcysn", crcySN));
		criteria.setMaxResults(1);
		return (Crcy)criteria.uniqueResult();
	}
	
	/**
	 * ���ԭsn����
	 * @param suppliersn
	 * @return
	 */
	public List<Crcy> findByNo(String no){
		Criteria criteria = this.getSession().createCriteria(Crcy.class);
		criteria.add(Restrictions.eq("crcysn", no));
		return criteria.list();
	}
}